<?php
namespace AuctionBack\Controller;

class MoneyScoreController extends BaseController
{
    
    public function __construct()
    {
        parent::__construct();
        $this->emp_id = $this->user_info['emp_id'];
    }
    
    public function index()
    {
        $p = I('get.p');
        $pageSize = 10;
        $status = I('get.status', 1);

        $condition = array('o.status' => $status);

        $orderSn = I('get.order_sn');
        $userId = I('get.user_id');
        $mobile = I('get.user_mobile');
        $startTime = strtotime(I('get.start_time'));
        $endTime = strtotime(I('get.end_time', 'strtotime'));

        if ($orderSn) {
            $condition['order_sn'] = $orderSn;
        }

        if ($userId) {
            $condition['user_id'] = $userId;
        }

        if ($mobile) {
            $condition['user_mobile'] = $mobile;
        }

        if ($startTime && $endTime) {
            $condition['create_time'] = array('between',array($startTime, $endTime));
        } elseif ($startTime) {
            $condition['create_time'] = array('gt',$startTime);
        } elseif ($endTime) {
            $condition['create_time'] = array('lt',$endTime);
        }


        $total = M('money_score_order o', 'au_', 'DB_CLCW')
            ->where($condition)
            ->count();

        $list = M('money_score_order o', 'au_', 'DB_CLCW')
            ->where($condition)
            ->order('id DESC')
            ->page($p, $pageSize)
            ->select();

        $Page = new \AuctionCore\Common\AjaxPage($total, $pageSize, "get_page");
        $Page->setConfig('theme', " %totalRow% %header% %nowPage%/%totalPage% 页 %first% %upPage% %prePage% %linkPage% %nextPage% %downPage%  %end% %jumpform%");
        $show = $Page->show();// 分页显示输出

        $this->assign('page', $show);
        $this->assign('list', $list);
        $this->display();
    }

    
    /**
     * 积分订单详情
     */
    public function orderDetail()
    {
        
        $id = I('get.id');
        
        $order = M('money_score_order', 'au_', 'DB_CLCW')->where(array('id'=>$id))->find();
           
        $this->assign('order', $order);
        $this->display();
    }
}
